home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d1
/
jd.arc
/
JD.C
next >
Wrap
Text File
|
1988-07-30
|
2KB
|
58 lines
/* This program copies the function of the CHDIR function of COMMAND.COM */
/* with extensions for extra options and access to Enviroment strings. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dir.h>
int main(int argc, char *argv[], char *env[])
{
int i, ErrN;
char opt[81], temp[81], token[81], *ptr;
if (argc > 1) /* Copy Cmd line */
{ strcpy(opt,argv[1]); /* parameter into */
strupr(opt); /* opt variable */
ErrN = chdir(opt); /* Try to change */
if (ErrN == 0) return(0); /* directories */
i = 0; /* Look thru enviroment */
while (env[i] != NULL) /* table for a match */
{ strcpy(temp,env[i]);
ptr = strchr(temp,'='); /* Enviroment String */
if (ptr != NULL) /* Enviroment Var Name */
{ *ptr = '\0';
strcpy(token,temp);
if (strcmp(opt,token) == 0) /* Match Found !!! */
{ strcpy(opt,ptr+1); /* Enviroment Assignment */
ErrN = chdir(opt); /* Try to change */
if (ErrN == 0) return(0); /* directory */
}
}
i++;
}
printf("Invalid directory\n");
return(1);
}
Do_Help();
return(1); /* Display help */
} /*main*/ /* screen */
int Do_Help()
{ printf("\n");
printf("JD.EXE <parameter>\n");
printf("<parameter> = Dos Path Name or Enviroment String Name\n");
printf("\n");
printf("JD version 1.0 copies the function of CHDIR with the extension\n");
printf("that enviroment strings names are allowed as parameters.\n");
printf("See also: SET, PATH, PROMPT ...\n");
} /* Do_Help */